import React from 'react';
import { useLocation } from 'react-router-dom';
import AdminLayout from './AdminLayout';
import AdminDashboard from './dashboard';
import UsersManagement from './users';
import RolesManagement from './roles';
import PermissionsManagement from './permissions';
import CrawlersManagement from './crawlers';
import SystemConfiguration from './system';

const AdminPage: React.FC = () => {
  const location = useLocation();
  
  const renderContent = () => {
    const path = location.pathname;
    
    if (path.startsWith('/admin/users')) {
      return <UsersManagement />;
    }
    
    if (path.startsWith('/admin/roles')) {
      return <RolesManagement />;
    }
    
    if (path.startsWith('/admin/permissions')) {
      return <PermissionsManagement />;
    }
    
    if (path.startsWith('/admin/crawlers')) {
      return <CrawlersManagement />;
    }
    
    if (path.startsWith('/admin/system')) {
      return <SystemConfiguration />;
    }
    
    // 默认显示仪表板
    return <AdminDashboard />;
  };
  
  return (
    <AdminLayout>
      {renderContent()}
    </AdminLayout>
  );
};

export default AdminPage;